/**
 * 项目名称:测试类
 *
 * @Author: 夏国倩
 * @Date: 2023/9/25 11:27
 * @Copyright
 */
package inner;
public class TestSwimming {
    public static void main(String[] args) {
        Swimming ss=new Swimming() {
            //匿名内部类使得代码更加简化
            @Override
            public void swim() {
                System.out.println("老师在游泳");
            }
        };
        go(ss); //老师游泳
        //匿名内部类可以作为方法的实际参数进行传输
        go(new Swimming() {
            @Override
            public void swim() {
                System.out.println("学生在游泳");
            }
        });
    }
    //准备开始
    public static void go(Swimming s){
        s.swim();
    }
}
